package com.enjoyor.soa.traffic.rest.tsms.dubbo.impl;

import java.util.List;

import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSONArray;
import com.enjoyor.soa.traffic.api.dto.tsms.RltRouteDeviceDto;
import com.enjoyor.soa.traffic.api.service.dubbo.tsms.IDubboRltRouteDeviceService;
import com.enjoyor.soa.traffic.api.ubms.dto.SignalSiteInfoDto;
import com.enjoyor.soa.traffic.api.ubms.dto.VideoAnalyzerInfoDto;
import com.enjoyor.soa.traffic.api.ubms.dto.VideoSiteInfoDto;
import com.enjoyor.soa.traffic.api.ubms.service.dubbo.DubboSignalSiteInfoService;
import com.enjoyor.soa.traffic.api.ubms.service.dubbo.DubboVideoSiteInfoService;
import com.enjoyor.soa.traffic.rest.tsms.dubbo.IRltRouteDeviceConsumeService;
import com.enjoyor.soa.traffic.util.pojo.Page;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

@Component
public class RltRouteDeviceConsumeService implements IRltRouteDeviceConsumeService {

	@Reference(version = "1.0.0", timeout = 10000)
	//@Reference(version = "1.0.0", timeout = 10000, url="dubbo://192.168.56.8:21241")
	private IDubboRltRouteDeviceService iDubboRltRouteDeviceService;
	@Reference(timeout = 10000)
	private DubboVideoSiteInfoService dubboVideoSiteInfoService;// 视频dubbo接口；
	@Reference(timeout = 10000)
	private DubboSignalSiteInfoService dubboSignalSiteInfoService;// 信号机dubbo接口

	@Override
	public ResultPojo getRltRouteDevicePage(Page page, String rltDeviceId, String taskId, String routeId, String deviceId,
			String deviceName, String deviceTypeId) {
		// TODO Auto-generated method stub
		return iDubboRltRouteDeviceService.getRltRouteDevicePage(page, rltDeviceId, taskId, routeId, deviceId, deviceName, deviceTypeId);
	}

	@Override
	public ResultPojo getRltRouteDeviceList(String rltDeviceId, String taskId, String routeId, String deviceId, String deviceName,
			String deviceTypeId) {
		// TODO Auto-generated m
		// 获取设备集合；
		List<RltRouteDeviceDto> listRltDevice = (List<RltRouteDeviceDto>) iDubboRltRouteDeviceService
				.getRltRouteDeviceList(rltDeviceId, taskId, routeId, deviceId, deviceName, deviceTypeId).getResultList();
		
		ResultPojo resultPojo = new ResultPojo();
		resultPojo.setResultList(listRltDevice);
		return resultPojo;
	}

	@Override
	public ResultPojo insertRltRouteDevice(RltRouteDeviceDto rltRouteDeviceDto, String personName) {
		// TODO Auto-generated method stub
		return iDubboRltRouteDeviceService.insertRltRouteDevice(rltRouteDeviceDto, personName);
	}

	@Override
	public ResultPojo editRltRouteDevice(RltRouteDeviceDto rltRouteDeviceDto, String personName) {
		// TODO Auto-generated method stub
		return iDubboRltRouteDeviceService.editRltRouteDevice(rltRouteDeviceDto, personName);
	}

	@Override
	public ResultPojo deleteRltRouteDevice(String rltDeviceId, String personName) {
		// TODO Auto-generated method stub
		return iDubboRltRouteDeviceService.deleteRltRouteDevice(rltDeviceId, personName);
	}

	@Override
	public ResultPojo rltRouteDeviceList(List<RltRouteDeviceDto> list, String taskId, String routeId,
			String deviceTypeId, String personName) {
		// TODO Auto-generated method stub
		//将json数组转化为对象list；
		//List<RltRouteDeviceDto> listDevice = JSONArray.parseArray(list, RltRouteDeviceDto.class);
		return iDubboRltRouteDeviceService.rltRouteDeviceList(list, taskId, routeId, deviceTypeId,personName);
	}

	@Override
	public ResultPojo replaceRouteDevice(RltRouteDeviceDto rltRouteDeviceDto, String rltDeviceId, String personName) {
		// TODO Auto-generated method stub
		return iDubboRltRouteDeviceService.replaceRouteDevice(rltRouteDeviceDto, rltDeviceId, personName);
	}

}
